// proxydll.cpp
#include "stdafx.h"
#include "proxydll.h"

// global variables
#pragma data_seg (".d3d9_shared")
myIDirect3DDevice9* gl_pmyIDirect3DDevice9;
myIDirect3D9*       gl_pmyIDirect3D9;
#pragma data_seg ()

BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    switch (ul_reason_for_call)
	{
	    case DLL_PROCESS_ATTACH: InitInstance(hModule); break;
	    case DLL_PROCESS_DETACH: ExitInstance(); break;
        
        case DLL_THREAD_ATTACH:  break;
	    case DLL_THREAD_DETACH:  break;
	}
    return TRUE;
}


HRESULT WINAPI Direct3DShaderValidatorCreate9(void)
{
    OutputDebugString("Direct3DShaderValidatorCreate9 not implemented.");
    return 0;
}

HRESULT WINAPI PSGPError(void)
{
    OutputDebugString("PSGPError not implemented.");
    return 0;
}

HRESULT WINAPI PSGPSampleTexture(void)
{
    OutputDebugString("PSGPSampleTexture not implemented.");
    return 0;
}

HRESULT WINAPI DebugSetLevel(void)
{
    OutputDebugString("DebugSetLevel not implemented.");
    return 0;
}

// Exported function (faking d3d9.dll's one-and-only export)
IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion)
{
	gl_pmyIDirect3D9 = new myIDirect3D9();
	return gl_pmyIDirect3D9;
}

void DebugSetMute(UINT mute)
{
	//MessageBox(NULL, __FUNCTION__, "Debug", MB_OK);
	sweglInfo("PROXYDLL: DebugSetMute(%d)\n", mute);
}

void InitInstance(HANDLE hModule) 
{
	OutputDebugString("PROXYDLL: InitInstance called.\r\n");
	gl_pmyIDirect3D9       = NULL;
}

void ExitInstance() 
{    
    OutputDebugString("PROXYDLL: ExitInstance called.\r\n");
}

